{% extends "submit/submit_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin static person_filters ietf_filters %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}I-D submission approvals{% endblock %}
{% load ietf_filters %}
{% block submit_content %}
    {% origin %}
    {% if user.is_authenticated %}
        <h2 class="mt-5" id="approvals">Submissions you can approve</h2>
        {% if not approvals %}
            <p class="alert alert-info my-3">
                You don't have any submissions to approve.
            </p>
        {% else %}
            <table class="approvals table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="draft">Internet-Draft</th>
                        <th scope="col" data-sort="date">Submitted</th>
                    </tr>
                </thead>
                <tbody>
                    {% for s in approvals %}
                        <tr>
                            <td>
                                <a href="{% url "ietf.submit.views.submission_status" submission_id=s.pk access_token=s.access_token %}">
                                    {{ s.name }}-{{ s.rev }}
                                </a>
                            </td>
                            <td>{{ s.submission_date }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% endif %}
        <h2 class="mt-5" id="preapprovals">Pre-approved Internet-Drafts not yet submitted</h2>
        {% if user|has_role:"Secretariat,WG Chair,RG Chair" %}
            <p>
                <a class="btn btn-primary"
                   href="{% url "ietf.submit.views.add_preapproval" %}">Add pre-approval</a>
            </p>
        {% endif %}
        {% if not preapprovals %}
            <p class="alert alert-info my-3">
                No pre-approvals within your jurisdiction found.
            </p>
        {% else %}
            <table class="preapprovals table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="draft">Internet-Draft name</th>
                        <th scope="col" data-sort="date">Pre-approved</th>
                        <th scope="col" data-sort="by">By</th>
                        <th scope="col"></th>
                    </tr>
                </thead>
                <tbody>
                    {% for p in preapprovals %}
                        <tr>
                            <td>{{ p.name|urlize_ietf_docs }}</td>
                            <td>{{ p.time|date:"Y-m-d" }}</td>
                            <td>{% person_link p.by %}</td>
                            <td>
                                <a class="btn btn-danger btn-sm float-end"
                                   href="{% url "ietf.submit.views.cancel_preapproval" preapproval_id=p.id %}">
                                    Cancel
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% endif %}
        <h2 class="mt-5" id="recently-approved">Approved Internet-Drafts within the past {{ days }} days</h2>
        {% if not recently_approved %}
            <p class="alert alert-info my-3">
                No Internet-Drafts approved.
            </p>
        {% else %}
            <table class="recently-approved table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="draft">Internet-Draft</th>
                        <th scope="col" data-sort="date">Submitted</th>
                    </tr>
                </thead>
                <tbody>
                    {% for d in recently_approved %}
                        <tr>
                            <td>
                                <a href="{% url "ietf.doc.views_doc.document_main" d.name %}">{{ d.name }}</a>
                            </td>
                            <td>{{ d.submission_date }}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% endif %}
    {% else %}
        <h2>Submission of approvals</h2>
        <p>
            This is where chairs and the secretariat can approve and pre-approve document
            submissions which require approval, such as WG <code>-00</code> Internet-Drafts.
        </p>
        <p>
            You need to
            <a href="https://{{ request.get_host }}/accounts/login/?next={{ request.get_full_path|urlencode }}"
               rel="nofollow">
                sign in
            </a>
            in order to handle approvals.
        </p>
    {% endif %}
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}